<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('spin_wheel_user', function (Blueprint $table) {
            $table->engine  = 'InnoDB';
            $table->comment('转盘抽奖用户');

            $table->increments('id');
            $table->integer('game_id')->comment('游戏id')->unsigned()->default(0);
            $table->string('openid', 128)->comment('渠道用户唯一id')->default('');
            $table->integer('reg_time')->comment('创建时间')->unsigned()->default(0);
            $table->integer('role_level')->comment('角色等级')->unsigned()->default(0);
            $table->double('total_pay_money', 16, 4)->comment('累计充值金额')->unsigned()->default(0);
            $table->integer('lottery_num')->comment('可用抽奖次数')->unsigned()->default(0);
            $table->integer('used_lottery_num')->comment('已用抽奖次数')->unsigned()->default(0);
            $table->integer('total_lottery_num')->comment('累计抽奖次数')->unsigned()->default(0);
            $table->integer('create_time')->comment('创建时间')->unsigned()->default(0);

            $table->index('game_id');
            $table->index('openid');
            $table->index('create_time');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('spin_wheel_user');
    }
};
